class Solution(object):
    def singleNumber(self, nums):
        """
        :type nums: List[int]
        :rtype: int
        """
        ans = 0
        for i in range(32):
            item = 0
            for k in nums:
                item += (k >> i) & 1
            item = item % 3
            if i == 31:
                ans -= (item << i)
            else:
                ans += (item << i)
        return ans


data = Solution()
nums = [0,1,0,1,0,1,-99]
print(data.singleNumber(nums))